package com.Controller;

import com.Service.OrderEngineerService;
import com.Utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/OrderEngineer")
public class OrderEngineerController {
    @Autowired
    private OrderEngineerService orderEngineerService;

    @PostMapping("/findOrders")
    public R findOrders(@RequestBody Map<String,String> Map_All){
        int flag= Integer.parseInt(Map_All.get("flag"));
        String tel=Map_All.get("tel");
        return new R(true,orderEngineerService.FindOrders(flag,tel));
    }

    @PostMapping("/EngineerAddMoney")
    public R EngineerAddMoney(@RequestBody Map<String,String> Map_All){
        BigDecimal money= new BigDecimal(Map_All.get("money"));
        String uuid=Map_All.get("orderUuid");
        String tel=Map_All.get("tel");
        return new R(orderEngineerService.EngineerAddMoney(uuid,tel,money)>0);
    }
    @PostMapping("/EngineerDelMoney")
    public R EngineerDelMoney(@RequestBody Map<String,String> Map_All){
        String uuid=Map_All.get("orderUuid");
        String tel=Map_All.get("tel");
        return new R(orderEngineerService.EngineerDelMoney(uuid,tel)>0);
    }

}
